package com.itheima.spring.cyclicDependency.proxy;

import net.sf.cglib.proxy.Enhancer;

public class MyEnhancer {

    private final MyProxy myProxy;
    private final Object object;

    public MyEnhancer(MyProxy myProxy, Object object) {
        this.myProxy = myProxy;
        this.object = object;
    }

    public Enhancer getEnhancer(){
        Enhancer enhancer = new Enhancer();  // 通过CGLIB动态代理获取代理对象的过程
        enhancer.setSuperclass(object.getClass());     // 设置enhancer对象的父类
        enhancer.setCallback(myProxy);    // 设置enhancer的回调对象
        return enhancer;
    }
}